<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>属性选择器</title>
    <script src="js/jquery-1.12.4.js"></script>
    <style type="text/css">
        #box {
            background-color: #FFF;
            border: 2px solid red;
            padding: 5px;
        }
    </style>
</head>

<body>
    <div id="box">
        <h2 class="odds" title="cartoonlist">游戏列表</h2>
        <h2 class="odds">游戏列表11</h2>

        <ul>
            <li class="odds" title="kn_jp">荒野行动</li>
            <li class="evens" title="hy_jp">绝地求生</li>
            <li class="odds" title="ss_jp">王者荣耀</li>
        </ul>
    </div>

    <script>
        // 属性选择器-包含[]
        $("h2[title]").css("background-color","#ccc")
        // class=odds设置背景颜色
        $("[class=odds]").css("background-color","#ccc")
        // 不等于！=
        $("[id!=box]").css("background-color","red")
        // 开头是h的设置背景颜色,^=
        $("[title^=h]").css("background-color","#aaa")
        // 对结尾进行设置，$=
        $("[title$=jp]").css("background-color","green")
        // 属性中包含某个字符，*=
        $("[title*=s]").css("background-color","blue")
        // 包含class,title属性中包含y，并且是li元素标签
        $("li[class][title*=y]").css("background-color","#fff")

    </script>


</body>

</html>